<cfcomponent accessors="true">	
    
    <cfproperty name="nclaverev"type="numeric">
    <cfproperty name="snombre">
	<cfproperty name="sdescripcion">
    <cfproperty name="nclavep"type="numeric">
    <cfproperty name="nclavet"type="numeric">
    <cfproperty name="fcostoa" type="numeric">
    <cfproperty name="fcostob" type="numeric">
    <cfproperty name="fcostoq" type="numeric">
    <cfproperty name="nclaver" type="numeric">
    <cfproperty name="nclavea" type="numeric">
    <cfproperty name="simagen"> 

	<cffunction name="buscarTodasRevistas"  access="remote" returntype="struct">
		<cfargument name="page" required="true" />
        <cfargument name="pageSize" required="true" />
        <cfargument name="gridsortcolumn" required="true" />
        <cfargument name="gridsortdirection" required="true" />
	
        
         <cfif arguments.gridsortcolumn eq "">
            <cfset arguments.gridsortcolumn = "nclaverev" />
            <cfset arguments.gridsortdirection = "asc" />
          </cfif>			            
        
        <cfquery name = "miq"  datasource="suscripcionesDSN"> 
        SELECT t1.nclaverev, t1.snombre, t1.sdescripcion, t1.nclavep,p.sdescripcion as perdescrip,t1.nclavet, m.sdescripcion as merdescrip, t1.fcostoa, fcostob, t1.fcostoq, t1.simagen
			FROM  revista as t1, tipomercado as m, periodicidad as p 
			WHERE m.nclavet = t1.nclavet AND  p.nclavep = t1.nclavep
            order by	#arguments.gridsortcolumn# #arguments.gridsortdirection#
        </cfquery>
        <cfreturn queryconvertforgrid(miq, page, pageSize)> 
	</cffunction>
	
	
	<cffunction name="insertar" returntype="void">
		<cfquery name="misql"datasource="suscripcionesDSN" >
	INSERT INTO revista (snombre, sdescripcion, nclaveP, nclaveT, fcostoA, fcostoB, fcostoQ, simagen)
	VALUES          ('#variables.snombre#',
			 '#variables.sdescripcion#',
			 #variables.nclavep#,
			#variables.nclavet#,
			#variables.fcostoa#,
			 #variables.fcostob#,
			 #variables.fcostoq#,
			'<img src="../images/revistas/no_disponible.png" border="0" width="60" height="90" />'				)

</cfquery>
	</cffunction>
	
	<cffunction name="modificar" returntype="void">
		<cfquery name="misql"datasource="suscripcionesDSN" >			
            UPDATE revista SET 
			snombre = '#variables.snombre#',
			sdescripcion = '#variables.sdescripcion#',
			nclavep = #variables.nclavep#,
			nclavet = #variables.nclavet#,
			fcostoa = #variables.fcostoa#,
			fcostob = #variables.fcostob#,
			fcostoq = #variables.fcostoq#
			WHERE nclaverev = #variables.nclaverev#
		</cfquery>
	</cffunction>

	<cffunction name="buscaid" returntype="numeric">
		<cfquery name="misql"datasource="suscripcionesDSN" >
		SELECT nclaverev 
		FROM revista ORDER BY nclaverev DESC LIMIT 1 
		</cfquery>
              cf
	</cffunction>
	
	<cffunction name="eliminalistaanun" returntype="void">
		<cfquery name="misql"datasource="suscripcionesDSN" >
			DELETE FROM listaanunciantes 
               		 WHERE nclaver=#variables.nclaver#
		</cfquery>
	</cffunction>

		<cffunction name="insertalistaanun" returntype="void">
		<cfquery name="misql"datasource="suscripcionesDSN" >
			INSERT INTO listaanunciantes
				(nclavea, nclaver)
				values(#variables.nclavea#,#variables.nclaver#)
		</cfquery>
		</cffunction>

	<cffunction name="eliminar" returntype="void">
		<cfquery name="misql">
			DELETE FROM revista
			WHERE nclaverev = #variables.nclaverev#
		</cfquery>
	</cffunction>
    
    <cffunction name = "buscaAnunciantes" returntype="array"> 
	    <cfquery name="misql">
        SELECT t1.nclavea, t1.snombre FROM  anunciantes as t1
        </cfquery>
        <cfreturn queryconvertforgrid(buscaAnunciantes, page, pageSize)> 
	</cffunction>
</cfcomponent>